import {createApp} from 'vue'
import {createPinia} from 'pinia'
import App from './App.vue'
import router from './router'
import {useAuthStore} from './stores/auth'

// 引入Element Plus
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

// 引入公共样式
import './styles/page-styles.css'

// 创建应用实例
const app = createApp(App)
const pinia = createPinia()

// 注册Element Plus图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 使用插件
app.use(pinia)
app.use(router)
app.use(ElementPlus, {
  size: 'default',
  zIndex: 3000
})


// 初始化认证状态（在应用启动时）
const authStore = useAuthStore()
authStore.initAuth()

console.log('[App] 应用初始化完成，认证状态:', authStore.isAuthenticated ? '已认证' : '未认证')

// 挂载应用
app.mount('#app')